package com.iweb.newa202104.filter;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Author: LGZ
 * @Date: 2021/5/12 18:09
 * @Description:
 */
@Slf4j
@WebFilter(urlPatterns = "/duration/*", filterName = "durationFilter")
public class DurationFilter implements Filter {

    private final String[] EXCLUDE_URL = {"/getAllByCategory", "/getAllByResource", "/getAll", "/getAllByUser" , "/getUserResource" , "/getUserCategory"};
    private final int PRE_URL_LENGTH = "/duration".length();

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void destroy() {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        FilterUtil.commonFilter(servletRequest, servletResponse, filterChain, PRE_URL_LENGTH, EXCLUDE_URL);
    }
}
